﻿using System.Globalization;

namespace ThirdServices.AlertModel
{
    public class AlertsLinks
    {
        private static string wunderAlert = @"http://api.wunderground.com/auto/wui/geo/AlertsXML/index.xml?query=";
        private static string wunderTemperatureAlert = @"http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=";
        private static string norwayWindAlert = @"http://api.yr.no/weatherapi/locationforecast/1.6/?";
        private static string irisEarthquakeAlertLink = @"http://www.iris.edu/servlet/eventserver/eventsXML.do?priority=time&PointsMax=";

        //@"http://api.yr.no/weatherapi/locationforecast/1.6/?lat=9.9424552;lon=51.5376872";

        /// <summary>
        /// Method returns global alerts for given lat,lon
        /// </summary>
        /// <param name="lat"></param>
        /// <param name="lon"></param>
        /// <returns></returns>
        public static string WunderAlertLink(double lat, double lon)
        {
            return wunderAlert + lat.ToString(CultureInfo.InvariantCulture) + "," +
                   lon.ToString(CultureInfo.InvariantCulture);
        }

        public static string NorwayWindAlertLink(double lat, double lon)
        {
            return norwayWindAlert + "lat=" + lat.ToString(CultureInfo.InvariantCulture) + ";lon=" +
                   lon.ToString(CultureInfo.InvariantCulture);
        }

        public static string WanderTempAlertLink(double lat, double lon)
        {
            return wunderTemperatureAlert + lat.ToString(CultureInfo.InvariantCulture) + "," +
                   lon.ToString(CultureInfo.InvariantCulture);
        }

        public static string IrisEarthquakeAlertLink(int pointsMax, double latMax, double latMin, double lonMax, double lonMin)
        {
            return irisEarthquakeAlertLink + pointsMax.ToString()
                + "&LatMax=" + latMax.ToString(CultureInfo.InvariantCulture)
                + "&LatMin=" + latMin.ToString(CultureInfo.InvariantCulture)
                + "&LonMax=" + latMax.ToString(CultureInfo.InvariantCulture)
                + "&LonMin=" + latMin.ToString(CultureInfo.InvariantCulture);
        }
    }
}
